import dayjs from "dayjs"


export const formatDate = (v: any) => {
  return v !== '-' ? dayjs(v).format('YYYY-MM-DD HH:mm:ss') : '-'
}

export const normalPath = (path: string,prefix?:string) => {
 
  return prefix?prefix+path:path
}

export function debounce(func:Function, wait:number) {
  let timeout;
  return function () {
    const context = this;
    const args = arguments;

    clearTimeout(timeout);

    timeout = setTimeout(function () {
      func.apply(context, args);
    }, wait);
  };
}

export function  downloadText(text, filename) {
  var blob = new Blob([text], { type: 'text/plain' });
  var url = URL.createObjectURL(blob);
  var a = document.createElement('a');
  a.href = url;
  a.download = filename;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
  URL.revokeObjectURL(url);
}
